10.2 Overview of Transport Layer Ports  
  10.2.3 Ports for clients  
Whenever a client connects to a service on a server, a source and destination port must be specified. TCP and UDP segments contain fields for source and destination ports. Destination ports, or ports for services, are normally defined using the well-known ports. Source ports set by the client are determined dynamically.

In general, a client determines the source port by randomly assigning a number above 1023. For instance, a client attempting to communicate with a web server uses TCP and assigns the destination port as 80 and the source port as 1045. When the packet arrives at the server, it passes up to the transport layer and eventually to the HTTP service which operates at port 80. The HTTP server responds to the clients request with a segment which uses port 80 as the source and 1045 as the destination. In this way, clients and servers use ports to distinguish what process the segment is associated with.

 

Web Links

Standard TCP and UDP Protocols

http://www.stearns.org/mason/ mason-6.html